import 'package:backend.core/core/domain/entities/app_store/app_store_transaction_revocation_info.dart';
import 'package:backend.purchases/domain/entities/app_store_api/app_store_api_transaction_revocation_info.dart';
import 'package:backend.purchases/domain/helpers/app_store/create_app_store_revocation_reason_from_api_one.dart';

abstract class CreateAppStoreTransactionRevocationInfoFromApiOne {
  AppStoreTransactionRevocationInfo call({
    required AppStoreApiTransactionRevocationInfo apiRevocationInfo,
  });
}

class CreateAppStoreTransactionRevocationInfoFromApiOneImpl
    implements CreateAppStoreTransactionRevocationInfoFromApiOne {
  const CreateAppStoreTransactionRevocationInfoFromApiOneImpl({
    required CreateAppStoreTransactionRevocationReasonFromApiOne
        createAppStoreTransactionRevocationReasonFromApiOne,
  }) : _createAppStoreTransactionRevocationReasonFromApiOne =
            createAppStoreTransactionRevocationReasonFromApiOne;

  final CreateAppStoreTransactionRevocationReasonFromApiOne
      _createAppStoreTransactionRevocationReasonFromApiOne;

  @override
  AppStoreTransactionRevocationInfo call({
    required AppStoreApiTransactionRevocationInfo apiRevocationInfo,
  }) {
    final revocationReason = _createAppStoreTransactionRevocationReasonFromApiOne(
      apiRevocationReason: apiRevocationInfo.reason,
    );

    return AppStoreTransactionRevocationInfo(
      reason: revocationReason,
      time: apiRevocationInfo.time,
    );
  }
}
